import Vue from 'vue'
import VueRouter from 'vue-router'
import Frame from '../src/components/frame.vue'
import Login from '../src/components/login.vue'
import { RouterTabRoutes } from 'vue-router-tab'

const importPage = (view) => () => import(`../page/${view}.vue`)

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Frame,
    meta: {
      title: '主页', // 页签标题
    },

    children: [
      // 引入 RouterTab 内置路由以支持 iframe 页签
      ...RouterTabRoutes,

      {
        path: '/', // 默认页和父级路由一致
        name: 'index',
        component: importPage('index'),
        meta: {
          title: '主页', // 页签标题
        },
      },
      {
        path: '/user',
        name: 'user',
        component: importPage('user/list'),
        meta: {
          title: '用户管理',
        },
      },
      {
        path: '/duplication',
        name: 'duplication',
        component: importPage('duplication/list'),
        meta: {
          title: '信息查重',
        },
      },
      {
        path: '/user/new',
        name: 'user_new',
        component: importPage('user/new'),
        meta: {
          title: '用户新增',
        },
      },
      {
        path: '/user/detail',
        name: 'user_detail',
        component: importPage('user/detail'),
        meta: {
          title: '用户详情',
        },
      },
      {
        path: '/role',
        name: 'role',
        component: importPage('role/list'),
        meta: {
          title: '角色列表',
        },
      },
      {
        path: '/role/new',
        name: 'role_new',
        component: importPage('role/new'),
        meta: {
          title: '新增角色',
        },
      },
      {
        path: '/role/detail',
        name: 'role_detail',
        component: importPage('role/detail'),
        meta: {
          title: '角色详细',
        },
      },
      {
        //permisson---------------------------------------------------------------------------------------------------------
        path: '/permission',
        name: 'permission',
        component: importPage('permission/list'),
        meta: {
          title: '权限列表',
        },
      },
      {
        path: '/permission/new',
        name: 'permission_new',
        component: importPage('permission/new'),
        meta: {
          title: '新增权限',
        },
      },
      {
        path: '/permission/detail',
        name: 'permission_detail',
        component: importPage('permission/detail'),
        meta: {
          title: '权限详细',
        },
      }, //permisson---------------------------------------------------------------------------------------------------------
      {
        //回访列表--------------------------------------------------------backview-------------------------------------------
        path: '/backview',
        name: 'backview',
        component: importPage('backview/list'),
        meta: {
          title: '回访列表',
        },
      },
      {
        //新增列表
        path: '/backview/new',
        name: 'backview_new',
        component: importPage('backview/new'),
        meta: {
          title: '新增回访',
        },
      },
      {
        //回访详细
        path: '/backview/detail',
        name: 'backview_detail',
        component: importPage('backview/detail'),
        meta: {
          title: '回访详细',
        },
      }, //--------------------------------------------------------backview-------------------------------------------
      //reservationInterview====================================
      {
        //预约接待列表
        path: '/reservationInterview',
        name: 'reservationInterview',
        component: importPage('reservationInterview/list'),
        meta: {
          title: '预约接待列表',
        },
      },
      {
        //新增预约接待
        path: '/reservationInterview/new',
        name: 'reservationInterview_new',
        component: importPage('reservationInterview/new'),
        meta: {
          title: '新增预约到访',
        },
      },
      {
        //预约接待详细
        path: '/reservationInterview/detail',
        name: 'reservationInterview_detail',
        component: importPage('reservationInterview/detail'),
        meta: {
          title: '预约接待详细',
        },
      },
      //reservationInterview==========================================
      //reservationBackview*******************************************************
      {
        //预约回访列表
        path: '/reservationBackview',
        name: 'reservationBackview',
        component: importPage('reservationBackview/list'),
        meta: {
          title: '预约回访列表',
        },
      },
      {
        //新增预约回访
        path: '/reservationBackview/new',
        name: 'reservationBackview_new',
        component: importPage('reservationBackview/new'),
        meta: {
          title: '新增预约回访',
        },
      },
      {
        //预约回访详细
        path: '/reservationBackview/detail',
        name: 'reservationBackview_detail',
        component: importPage('reservationBackview/detail'),
        meta: {
          title: '预约回访详细',
        },
      },
      //reservationBackview*******************************************************
      //reservationTry+++++++++++++++++++++++++++++++++++++++++++++++
      {
        //预约试听列表
        path: '/reservationTry',
        name: 'reservationTry',
        component: importPage('reservationTry/list'),
        meta: {
          title: '预约试听列表',
        },
      },
      {
        //新增预约试听
        path: '/reservationTry/new',
        name: 'reservationTry_new',
        component: importPage('reservationTry/new'),
        meta: {
          title: '新增预约试听',
        },
      },
      {
        //预约试听详细
        path: '/reservationTry/detail',
        name: 'reservationTry_detail',
        component: importPage('reservationTry/detail'),
        meta: {
          title: '预约试听详细',
        },
      },
      //reservationTry+++++++++++++++++++++++++++++++++++++++++++++++++
      //publicSea //////////////////////////////////////////////////////////////////
      {
        //公海列表
        path: '/publicSea',
        name: 'publicSea',
        component: importPage('publicSea/list'),
        meta: {
          title: '公海列表',
        },
      },
      {
        //新增预约试听
        path: '/publicSea/new',
        name: 'publicSea_new',
        component: importPage('publicSea/new'),
        meta: {
          title: '新增预约试听',
        },
      },
      {
        //预约试听详细
        path: '/publicSea/detail',
        name: 'publicSea_detail',
        component: importPage('publicSea/detail'),
        meta: {
          title: '学生个人信息详情',
        },
      }, //公海------------------------------------------
      //学生线索详细
      {
        path: '/publicSea/resource',
        name: 'publicSea_resource',
        component: importPage('publicSea/resourceDetail'),
        meta: {
          title: '学生线索详细',
        },
      },

      //学生接待详细
      {
        path: '/publicSea/interview',
        name: 'publicSea_interview',
        component: importPage('publicSea/interviewDetail'),
        meta: {
          title: '学生接待详细',
        },
      },
      //学生试听详细
      {
        path: '/publicSea/try',
        name: 'publicSea_try',
        component: importPage('publicSea/tryDetail'),
        meta: {
          title: '学生试听详细',
        },
      },
      //阶段回访列表************************
      //publicSea //////////////////////////////////////////////////////////////////
      {
        path: 'resourceBackview/list',
        name: 'resourceBackview_list',
        component: importPage('publicSea/resourceBackview'),
        meta: {
          title: '学生线索阶段回访列表',
        },
      },
      {
        path: '/interviewBackview/list',
        name: 'interviewBackview_list',
        component: importPage('publicSea/interviewBackview'),
        meta: {
          title: '学生接待阶段回访列表',
        },
      },
      {
        path: '/tryBackview/list',
        name: 'tryBackview_list',
        component: importPage('publicSea/tryBackview'),
        meta: {
          title: '学生试听阶段回访列表',
        },
      },
      //-----------------------------------------------------------------------------student
      {
        //回访列表--------------------------------------------------------backview-------------------------------------------
        path: '/student',
        name: 'student',
        component: importPage('student/list'),
        meta: {
          title: '学生列表',
        },
      },
      {
        path: '/student/new',
        name: 'student_new',
        component: importPage('student/new'),
        meta: {
          title: '新增学生',
        },
      },
      {
        path: '/student/detail',
        name: 'student_detail',
        component: importPage('student/detail'),
        meta: {
          title: '学生详细',
          // keepAlive:false
        },
      },
      {
        path: '/resource',
        name: 'resource',
        component: importPage('resource/list'),
        meta: {
          title: '线索信息',
        },
      },
      {
        path: '/resource/new',
        name: 'resource_new',
        component: importPage('resource/new'),
        meta: {
          title: '新增线索',
        },
      },
      {
        path: '/resource/detail',
        name: 'resource_detail',
        component: importPage('resource/detail'),
        meta: {
          title: '线索详细',
        },
      },
      {
        path: '/interview',
        name: 'interview',
        component: importPage('interview/list'),
        meta: {
          title: '到访信息',
        },
      },
      {
        path: '/interview/new',
        name: 'interview_new',
        component: importPage('interview/new'),
        meta: {
          title: '新增到访',
        },
      },
      {
        path: '/interview/detail',
        name: 'interview_detail',
        component: importPage('interview/detail'),
        meta: {
          title: '到访详细',
        },
      },
      {
        path: '/try',
        name: 'try',
        component: importPage('try/list'),
        meta: {
          title: '试听信息',
        },
      },
      {
        path: '/try/new',
        name: 'try_new',
        component: importPage('try/new'),
        meta: {
          title: '新增试听',
        },
      },
      {
        path: '/try/detail',
        name: 'try_detail',
        component: importPage('try/detail'),
        meta: {
          title: '试听详细',
        },
      },
      {
        path: '/baoming',
        name: 'baoming',
        component: importPage('baoming/list'),
        meta: {
          title: '报名信息',
        },
      },
      {
        path: '/baoming/new',
        name: 'baoming_new',
        component: importPage('baoming/new'),
        meta: {
          title: '新增报名',
        },
      },
      {
        path: '/baoming/detail',
        name: 'baoming_detail',
        component: importPage('baoming/detail'),
        meta: {
          title: '报名详细',
        },
      },
      {
        path: '/baoming/again',
        name: 'baoming_again',
        component: importPage('baoming/again'),
        meta: {
          title: '重新申请',
        },
      },

      {
        path: '/student/lifeCycle',
        name: 'student_lifeCycle',
        component: importPage('student/lifeCycle'),
        meta: {
          title: '生命周期',
        },
      },
      {
        path: '/statistics',
        name: 'statistics',
        component: importPage('statistics/list'),
        meta: {
          title: '市场信息',
        },
      },
      {
        path: '/infoStatistics',
        name: 'infoStatistics',
        component: importPage('infoStatistics/list'),
        meta: {
          title: '市场信息',
        },
      },
      {
        path: '/paymentStatistics',
        name: 'paymentStatistics',
        component: importPage('paymentStatistics/list'),
        meta: {
          title: '分期统计',
        },
      },
      {
        path: '/paymentStatistics/daiqueren',
        name: 'daiqueren',
        component: importPage('paymentStatistics/daiqueren'),
        meta: {
          title: '待确认信息',
        },
      },
      {
        path: '/paymentStatistics/yishengxiao',
        name: 'yishengxiao',
        component: importPage('paymentStatistics/yishengxiao'),
        meta: {
          title: '已生效信息',
        },
      },
      {
        path: '/paymentStatistics/huankuanzhong',
        name: 'huankuanzhong',
        component: importPage('paymentStatistics/huankuanzhong'),
        meta: {
          title: '还款中信息',
        },
      },
      {
        path: '/paymentStatistics/yiquxiao',
        name: 'yiquxiao',
        component: importPage('paymentStatistics/yiquxiao'),
        meta: {
          title: '已取消信息',
        },
      },
      {
        path: '/paymentStatistics/yijieqing',
        name: 'yijieqing',
        component: importPage('paymentStatistics/yijieqing'),
        meta: {
          title: '已结清信息',
        },
      },
      {
        path: '/paymentStatistics/weitongguo',
        name: 'weitongguo',
        component: importPage('paymentStatistics/weitongguo'),
        meta: {
          title: '未通过信息',
        },
      },
      {
        path: '/paymentStatistics/yuqiweifu',
        name: 'yuqiweifu',
        component: importPage('paymentStatistics/yuqiweifu'),
        meta: {
          title: '逾期未付信息',
        },
      },
      {
        path: '/paymentStatistics/yihuankuandaiqueren',
        name: 'yihuankuandaiqueren',
        component: importPage('paymentStatistics/yihuankuandaiqueren'),
        meta: {
          title: '已还款待确认信息',
        },
      },
      {
        path: '/paymentStatistics/revenue',
        name: 'revenue',
        component: importPage('paymentStatistics/revenue'),
        meta: {
          title: '收入查询',
        },
      },
      {
        path: '/trainee',
        name: 'trainee',
        component: importPage('trainee/list'),
        meta: {
          title: '学员管理',
        },
      },
      {
        path: '/paymentItem',
        name: 'paymentItem',
        component: importPage('paymentItem/list'),
        meta: {
          title: '分期计划',
        },
      },
      {
        path: '/projectService',
        name: 'projectService',
        component: importPage('projectService/list'),
        meta: {
          title: '服务信息',
        },
      },
      {
        path: '/projectService/new',
        name: 'projectService_new',
        component: importPage('projectService/new'),
        meta: {
          title: '新增服务',
        },
      },
      {
        path: '/projectService/detail',
        name: 'projectService_detail',
        component: importPage('projectService/detail'),
        meta: {
          title: '服务详细',
        },
      },
      {
        path: '/paymentOptions',
        name: 'paymentOptions',
        component: importPage('paymentOptions/list'),
        meta: {
          title: '分期服务信息',
        },
      },
      {
        path: '/paymentOptions/new',
        name: 'paymentOptions_new',
        component: importPage('paymentOptions/new'),
        meta: {
          title: '新增分期服务',
        },
      },
      {
        path: '/paymentOptions/detail',
        name: 'paymentOptions_detail',
        component: importPage('paymentOptions/detail'),
        meta: {
          title: '分期服务详细',
        },
      },
      {
        path: '/page/:id',
        name: 'Page',
        component: importPage('Page'),
        meta: {
          key: 'path',
          title(route) {
            return `Page ${route.params.id}`
          },
        },
      },
    ],
  },
  {
    path: '/',
    name: 'login',
    component: Login,
  },
]
const router = new VueRouter({
  routes,
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
}

export default router
